import java.util.Scanner;
public class Test5 {
    public static void main(String[] args) {
        Scanner sca=new Scanner(System.in);
        String password="123456";
        for (int i = 3; i >0 ; i--) {
            System.out.println("请输入密码（剩余次数"+ i+"）");
            String input= sca.nextLine();
            if(password.equals(input)){
                System.out.println("登陆成功");
                sca.close();
                return;
            }else {
                System.out.println(i>1 ?"密码错误，请重新输入":"已错误三次，退出程序");
            }
        }sca.close();
    }
}
